import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/user_account_alloc_entity.dart';

UserAccountAllocEntity $UserAccountAllocEntityFromJson(
    Map<String, dynamic> json) {
  final UserAccountAllocEntity userAccountAllocEntity = UserAccountAllocEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    userAccountAllocEntity.total = total;
  }
  final double? totalRemain = jsonConvert.convert<double>(json['totalRemain']);
  if (totalRemain != null) {
    userAccountAllocEntity.totalRemain = totalRemain;
  }
  final List<UserAccountAllocData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<UserAccountAllocData>(e) as UserAccountAllocData)
      .toList();
  if (data != null) {
    userAccountAllocEntity.data = data;
  }
  return userAccountAllocEntity;
}

Map<String, dynamic> $UserAccountAllocEntityToJson(
    UserAccountAllocEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['totalRemain'] = entity.totalRemain;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension UserAccountAllocEntityExtension on UserAccountAllocEntity {
  UserAccountAllocEntity copyWith({
    int? total,
    double? totalRemain,
    List<UserAccountAllocData>? data,
  }) {
    return UserAccountAllocEntity()
      ..total = total ?? this.total
      ..totalRemain = totalRemain ?? this.totalRemain
      ..data = data ?? this.data;
  }
}

UserAccountAllocData $UserAccountAllocDataFromJson(Map<String, dynamic> json) {
  final UserAccountAllocData userAccountAllocData = UserAccountAllocData();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    userAccountAllocData.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    userAccountAllocData.title = title;
  }
  final int? updatedAt = jsonConvert.convert<int>(json['updatedAt']);
  if (updatedAt != null) {
    userAccountAllocData.updatedAt = updatedAt;
  }
  final String? collectionDate = jsonConvert.convert<String>(
      json['collectionDate']);
  if (collectionDate != null) {
    userAccountAllocData.collectionDate = collectionDate;
  }
  final String? orderAmount = jsonConvert.convert<String>(json['orderAmount']);
  if (orderAmount != null) {
    userAccountAllocData.orderAmount = orderAmount;
  }
  final int? payAmount = jsonConvert.convert<int>(json['payAmount']);
  if (payAmount != null) {
    userAccountAllocData.payAmount = payAmount;
  }
  final String? agentUid = jsonConvert.convert<String>(json['agentUid']);
  if (agentUid != null) {
    userAccountAllocData.agentUid = agentUid;
  }
  final String? agentUsername = jsonConvert.convert<String>(
      json['agentUsername']);
  if (agentUsername != null) {
    userAccountAllocData.agentUsername = agentUsername;
  }
  final int? allocStatus = jsonConvert.convert<int>(json['allocStatus']);
  if (allocStatus != null) {
    userAccountAllocData.allocStatus = allocStatus;
  }
  final String? allocContent = jsonConvert.convert<String>(
      json['allocContent']);
  if (allocContent != null) {
    userAccountAllocData.allocContent = allocContent;
  }
  final UserAccountAllocDataInvoiceObj? invoiceObj = jsonConvert.convert<
      UserAccountAllocDataInvoiceObj>(json['invoiceObj']);
  if (invoiceObj != null) {
    userAccountAllocData.invoiceObj = invoiceObj;
  }
  final int? marginAmount = jsonConvert.convert<int>(json['marginAmount']);
  if (marginAmount != null) {
    userAccountAllocData.marginAmount = marginAmount;
  }
  final dynamic marginDate = json['marginDate'];
  if (marginDate != null) {
    userAccountAllocData.marginDate = marginDate;
  }
  final String? uid = jsonConvert.convert<String>(json['uid']);
  if (uid != null) {
    userAccountAllocData.uid = uid;
  }
  final String? mobile = jsonConvert.convert<String>(json['mobile']);
  if (mobile != null) {
    userAccountAllocData.mobile = mobile;
  }
  final double? availableAmount = jsonConvert.convert<double>(
      json['availableAmount']);
  if (availableAmount != null) {
    userAccountAllocData.availableAmount = availableAmount;
  }
  final int? remainAmount = jsonConvert.convert<int>(json['remainAmount']);
  if (remainAmount != null) {
    userAccountAllocData.remainAmount = remainAmount;
  }
  final String? updatedAtStr = jsonConvert.convert<String>(
      json['updatedAtStr']);
  if (updatedAtStr != null) {
    userAccountAllocData.updatedAtStr = updatedAtStr;
  }
  final UserAccountAllocDataSettle? settle = jsonConvert.convert<
      UserAccountAllocDataSettle>(json['settle']);
  if (settle != null) {
    userAccountAllocData.settle = settle;
  }
  final bool? isManOrder = jsonConvert.convert<bool>(json['isManOrder']);
  if (isManOrder != null) {
    userAccountAllocData.isManOrder = isManOrder;
  }
  return userAccountAllocData;
}

Map<String, dynamic> $UserAccountAllocDataToJson(UserAccountAllocData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['title'] = entity.title;
  data['updatedAt'] = entity.updatedAt;
  data['collectionDate'] = entity.collectionDate;
  data['orderAmount'] = entity.orderAmount;
  data['payAmount'] = entity.payAmount;
  data['agentUid'] = entity.agentUid;
  data['agentUsername'] = entity.agentUsername;
  data['allocStatus'] = entity.allocStatus;
  data['allocContent'] = entity.allocContent;
  data['invoiceObj'] = entity.invoiceObj.toJson();
  data['marginAmount'] = entity.marginAmount;
  data['marginDate'] = entity.marginDate;
  data['uid'] = entity.uid;
  data['mobile'] = entity.mobile;
  data['availableAmount'] = entity.availableAmount;
  data['remainAmount'] = entity.remainAmount;
  data['updatedAtStr'] = entity.updatedAtStr;
  data['settle'] = entity.settle.toJson();
  data['isManOrder'] = entity.isManOrder;
  return data;
}

extension UserAccountAllocDataExtension on UserAccountAllocData {
  UserAccountAllocData copyWith({
    String? id,
    String? title,
    int? updatedAt,
    String? collectionDate,
    String? orderAmount,
    int? payAmount,
    String? agentUid,
    String? agentUsername,
    int? allocStatus,
    String? allocContent,
    UserAccountAllocDataInvoiceObj? invoiceObj,
    int? marginAmount,
    dynamic marginDate,
    String? uid,
    String? mobile,
    double? availableAmount,
    int? remainAmount,
    String? updatedAtStr,
    UserAccountAllocDataSettle? settle,
    bool? isManOrder,
  }) {
    return UserAccountAllocData()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..updatedAt = updatedAt ?? this.updatedAt
      ..collectionDate = collectionDate ?? this.collectionDate
      ..orderAmount = orderAmount ?? this.orderAmount
      ..payAmount = payAmount ?? this.payAmount
      ..agentUid = agentUid ?? this.agentUid
      ..agentUsername = agentUsername ?? this.agentUsername
      ..allocStatus = allocStatus ?? this.allocStatus
      ..allocContent = allocContent ?? this.allocContent
      ..invoiceObj = invoiceObj ?? this.invoiceObj
      ..marginAmount = marginAmount ?? this.marginAmount
      ..marginDate = marginDate ?? this.marginDate
      ..uid = uid ?? this.uid
      ..mobile = mobile ?? this.mobile
      ..availableAmount = availableAmount ?? this.availableAmount
      ..remainAmount = remainAmount ?? this.remainAmount
      ..updatedAtStr = updatedAtStr ?? this.updatedAtStr
      ..settle = settle ?? this.settle
      ..isManOrder = isManOrder ?? this.isManOrder;
  }
}

UserAccountAllocDataInvoiceObj $UserAccountAllocDataInvoiceObjFromJson(
    Map<String, dynamic> json) {
  final UserAccountAllocDataInvoiceObj userAccountAllocDataInvoiceObj = UserAccountAllocDataInvoiceObj();
  final String? showTab = jsonConvert.convert<String>(json['showTab']);
  if (showTab != null) {
    userAccountAllocDataInvoiceObj.showTab = showTab;
  }
  final String? email = jsonConvert.convert<String>(json['email']);
  if (email != null) {
    userAccountAllocDataInvoiceObj.email = email;
  }
  final List<
      UserAccountAllocDataInvoiceObjRelateCases>? relateCases = (json['relateCases'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<UserAccountAllocDataInvoiceObjRelateCases>(
          e) as UserAccountAllocDataInvoiceObjRelateCases).toList();
  if (relateCases != null) {
    userAccountAllocDataInvoiceObj.relateCases = relateCases;
  }
  final List<dynamic>? orderAttachs = (json['orderAttachs'] as List<dynamic>?)
      ?.map(
          (e) => e)
      .toList();
  if (orderAttachs != null) {
    userAccountAllocDataInvoiceObj.orderAttachs = orderAttachs;
  }
  final String? invoiceStatusTime = jsonConvert.convert<String>(
      json['invoiceStatusTime']);
  if (invoiceStatusTime != null) {
    userAccountAllocDataInvoiceObj.invoiceStatusTime = invoiceStatusTime;
  }
  final String? invoiceStatusTaker = jsonConvert.convert<String>(
      json['invoiceStatusTaker']);
  if (invoiceStatusTaker != null) {
    userAccountAllocDataInvoiceObj.invoiceStatusTaker = invoiceStatusTaker;
  }
  return userAccountAllocDataInvoiceObj;
}

Map<String, dynamic> $UserAccountAllocDataInvoiceObjToJson(
    UserAccountAllocDataInvoiceObj entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['showTab'] = entity.showTab;
  data['email'] = entity.email;
  data['relateCases'] = entity.relateCases.map((v) => v.toJson()).toList();
  data['orderAttachs'] = entity.orderAttachs;
  data['invoiceStatusTime'] = entity.invoiceStatusTime;
  data['invoiceStatusTaker'] = entity.invoiceStatusTaker;
  return data;
}

extension UserAccountAllocDataInvoiceObjExtension on UserAccountAllocDataInvoiceObj {
  UserAccountAllocDataInvoiceObj copyWith({
    String? showTab,
    String? email,
    List<UserAccountAllocDataInvoiceObjRelateCases>? relateCases,
    List<dynamic>? orderAttachs,
    String? invoiceStatusTime,
    String? invoiceStatusTaker,
  }) {
    return UserAccountAllocDataInvoiceObj()
      ..showTab = showTab ?? this.showTab
      ..email = email ?? this.email
      ..relateCases = relateCases ?? this.relateCases
      ..orderAttachs = orderAttachs ?? this.orderAttachs
      ..invoiceStatusTime = invoiceStatusTime ?? this.invoiceStatusTime
      ..invoiceStatusTaker = invoiceStatusTaker ?? this.invoiceStatusTaker;
  }
}

UserAccountAllocDataInvoiceObjRelateCases $UserAccountAllocDataInvoiceObjRelateCasesFromJson(
    Map<String, dynamic> json) {
  final UserAccountAllocDataInvoiceObjRelateCases userAccountAllocDataInvoiceObjRelateCases = UserAccountAllocDataInvoiceObjRelateCases();
  final String? caseId = jsonConvert.convert<String>(json['caseId']);
  if (caseId != null) {
    userAccountAllocDataInvoiceObjRelateCases.caseId = caseId;
  }
  final String? caseName = jsonConvert.convert<String>(json['caseName']);
  if (caseName != null) {
    userAccountAllocDataInvoiceObjRelateCases.caseName = caseName;
  }
  final String? time = jsonConvert.convert<String>(json['time']);
  if (time != null) {
    userAccountAllocDataInvoiceObjRelateCases.time = time;
  }
  return userAccountAllocDataInvoiceObjRelateCases;
}

Map<String, dynamic> $UserAccountAllocDataInvoiceObjRelateCasesToJson(
    UserAccountAllocDataInvoiceObjRelateCases entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['caseId'] = entity.caseId;
  data['caseName'] = entity.caseName;
  data['time'] = entity.time;
  return data;
}

extension UserAccountAllocDataInvoiceObjRelateCasesExtension on UserAccountAllocDataInvoiceObjRelateCases {
  UserAccountAllocDataInvoiceObjRelateCases copyWith({
    String? caseId,
    String? caseName,
    String? time,
  }) {
    return UserAccountAllocDataInvoiceObjRelateCases()
      ..caseId = caseId ?? this.caseId
      ..caseName = caseName ?? this.caseName
      ..time = time ?? this.time;
  }
}

UserAccountAllocDataSettle $UserAccountAllocDataSettleFromJson(
    Map<String, dynamic> json) {
  final UserAccountAllocDataSettle userAccountAllocDataSettle = UserAccountAllocDataSettle();
  final String? ratio = jsonConvert.convert<String>(json['ratio']);
  if (ratio != null) {
    userAccountAllocDataSettle.ratio = ratio;
  }
  final String? settleAmount = jsonConvert.convert<String>(
      json['settleAmount']);
  if (settleAmount != null) {
    userAccountAllocDataSettle.settleAmount = settleAmount;
  }
  return userAccountAllocDataSettle;
}

Map<String, dynamic> $UserAccountAllocDataSettleToJson(
    UserAccountAllocDataSettle entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['ratio'] = entity.ratio;
  data['settleAmount'] = entity.settleAmount;
  return data;
}

extension UserAccountAllocDataSettleExtension on UserAccountAllocDataSettle {
  UserAccountAllocDataSettle copyWith({
    String? ratio,
    String? settleAmount,
  }) {
    return UserAccountAllocDataSettle()
      ..ratio = ratio ?? this.ratio
      ..settleAmount = settleAmount ?? this.settleAmount;
  }
}